package com.bohua.child.controller;

import com.bohua.child.common.Lay;
import com.bohua.child.common.Msg;
import com.bohua.child.entity.User;
import com.bohua.child.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
/**
 * 用户表控制器
 * @author shichenyang
 * @email gyv12345@163.com
 * @date 2019/02/19
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping
    public String user(){
        return "user/user.html";
    }
    @RequestMapping("/add")
    public String add(){
        return "user/addUser.html";
    }

    @RequestMapping("/update")
    public String update(){
        return "user/updateUser.html";
    }

    @RequestMapping("/getUsers")
    @ResponseBody
    public Lay getUsers(User user, Integer page, Integer limit){
        return userService.getUsers(user,page,limit);
    }
    @RequestMapping("/addUser")
    @ResponseBody
    public Msg addUser(User user){
        return userService.addUser(user);
    }

    @RequestMapping("/updateUser")
    @ResponseBody
    public Msg updateUser(User user){
        return userService.updateUser(user);
    }

    @RequestMapping("/login")
    public String login(User user)
    {
        return "login/login.html";
    }
    @RequestMapping("/delUser")
    @ResponseBody
    public Msg delUser(User user){
        return userService.delUser(user);
    }
}
